package com.dcncy.excel.exec;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.dcncy.excel.exec.vo.Area;
import com.dcncy.excel.exec.vo.City;
import com.dcncy.excel.exec.vo.Province;
import com.dcncy.excel.exec.vo.Student;
import com.dcncy.excel.util.DBUtil;

public class GetData {

    // 查询出所有省份
    public static List<Province> getProvinces() {

        List<Province> list = new ArrayList<Province>();
        for (int i = 0; i < 10; i++) {
            Province province = new Province();
            province.setProvinceId(("PROVINCE_ID") + i);
            province.setProvinceName(("PROVINCE_NAME") + i);
            list.add(province);
        }
        /*List<Map<String, Object>> provinceList = new ArrayList<Map<String, Object>>();
        String sql = "select PROVINCE_ID,PROVINCE_NAME from EXCEL_PROVINCE";
        try {
            provinceList = DBUtil.query(sql);

            for (Map<String, Object> map : provinceList) {
                Province province = new Province();
                province.setProvinceId((String) map.get("PROVINCE_ID"));
                province.setProvinceName((String) map.get("PROVINCE_NAME"));
                list.add(province);
            }
        }
        catch (SQLException e) {
            e.printStackTrace();
        }*/
        return list;
    }

    // 查询出所有地区
    public static List<Area> getAreas(String provinceId) {
        List<Area> list = new ArrayList<Area>();
        for (int i = 0; i < 10; i++) {
            Area area = new Area();
            area.setAreaId(("AREA_ID") + i);
            area.setAreaName(("AREA_NAME") + i);
            list.add(area);
        }
        /*List<Map<String, Object>> areaList = new ArrayList<Map<String, Object>>();
        String sql = "SELECT AREA_ID,AREA_NAME FROM EXCEL_AREA where PROVINCE_ID='" + provinceId + "'";
        try {
            areaList = DBUtil.query(sql);

            for (Map<String, Object> map : areaList) {
                Area area = new Area();
                area.setAreaId((String) map.get("AREA_ID"));
                area.setAreaName((String) map.get("AREA_NAME"));
                list.add(area);
            }
        }
        catch (SQLException e) {
            e.printStackTrace();
        }*/
        return list;
    }

    // 查询出所有城市
    public static List<City> getCities(String areaId) {
        List<City> list = new ArrayList<City>();
        for (int i = 0; i < 10; i++) {
            City city = new City();
            city.setCityId(("CITY_ID") + i);
            city.setCityName(("CITY_NAME") + i);
            list.add(city);
        }
        /*List<Map<String, Object>> cityList = new ArrayList<Map<String, Object>>();
        String sql = "SELECT CITY_ID,CITY_NAME FROM EXCEL_CITY where AREA_ID='" + areaId + "'";
        try {
            cityList = DBUtil.query(sql);

            for (Map<String, Object> map : cityList) {
                City city = new City();
                city.setCityId((String) map.get("CITY_ID"));
                city.setCityName((String) map.get("CITY_NAME"));
                list.add(city);
            }
        }
        catch (SQLException e) {
            e.printStackTrace();
        }*/
        return list;
    }

    public static List<Student> getStudents() {
        List<Student> stuNameList = new ArrayList<Student>();
        Student s1 = new Student("jack", "河南省", "郑州市", "新郑");
        Student s2 = new Student("Tomi", "河北省", "唐山市", "唐山");
        Student s3 = new Student("Lucy", "辽宁省", "大连市", "甘井子");

        stuNameList.add(s1);
        stuNameList.add(s2);
        stuNameList.add(s3);

        return stuNameList;
    }
}
